<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef APP-PLUS
			this.checknetwork()
			setTimeout(() => {
				plus.navigator.closeSplashscreen();
			}, 3000);
			
			// #endif
			
		},
		onShow: function() {
			uni.setStorageSync('lower', '1')
			console.log('App Show')
			// #ifdef MP-WEIXIN
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
			});
			updateManager.onUpdateReady(function(res) {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，重启应用以更新',
					success(res) {
						if (res.confirm) {
							// 用户点击确定
							// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
							updateManager.applyUpdate();
						} else if (res.cancel) {
							// 用户点击取消
						}
					}
				});
			});
			updateManager.onUpdateFailed(function(res) {
				// 新的版本下载失败
			});
			// #endif
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			checknetwork() {
				uni.onNetworkStatusChange(function(res) {
					if (res.isConnected) {

						uni.setStorageSync('lower', '1')
						uni.reLaunch({
							url: '/pages/index/index'
						})
					} else {
						uni.showModal({
							title: '系统提示',
							content: '当前设备无网络或网络较差',
							cancelText: '取消',
							confirmText: '确定',
							success: (res) => {
								if (res.confirm) {
									uni.setStorageSync('lower', '1')
									uni.reLaunch({
										url: '/pages/index/index'
									})
								} else {
									// #ifdef H5
									uni.reLaunch({
										url: '/pages/index/index'
									})
									// #endif
									// #ifdef APP-PLUS
									plus.runtime.quit()
									// #endif
								}
							}
						})
					}
				})
			}
		}
	}
</script>
<style>
	/*每个页面公共css */
	@font-face {
		font-family: 'youshe';
		src: url('https://www.dingxians.cn/upload/font/youshe.ttf');
	}

	.btn-primary {
		background: rgba(0, 0, 0, 0.37);
		box-shadow: inset 0 0 36rpx 0 rgba(0, 220, 255, 0.45);
		border-radius: 40rpx;
		/* border: 1rpx solid;
  border-image: linear-gradient(360deg, rgba(0, 220.00000208616257, 255, 1), rgba(112.79845967888832, 50.77433466911316, 255, 1)) 1 1;*/
	}

	.item-bg {
		background: rgba(0, 0, 0, 0.37);
		box-shadow: inset 0 0 36rpx 0 rgba(0, 220, 255, 0.45);
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		border: 1rpx solid #00DCFF;
		/*border-image: linear-gradient(360deg, rgba(0, 220.00000208616257, 255, 1), rgba(112.79845967888832, 50.77433466911316, 255, 1)) 1 1;*/
	}

	@keyframes anim-box-normal {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -14016rpx;
		}
	}

	@keyframes anim-history-epic {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -4032rpx;
		}
	}

	/* 因为普通商品不用显示动画，故写出此代码节省时间 */
	@keyframes anim-history-legend {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -4032rpx;
		}
	}

	@keyframes anim-1 {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -16320rpx;
		}
	}

	@keyframes anim-2 {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -9840rpx;
		}
	}

	@keyframes anim-3 {
		from {
			background-position: 0 0;
		}

		to {
			background-position: 0 -7920rpx;
		}
	}
</style>